package com.smarth.zhizulian.utils;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.request.RequestOptions;
import com.smarth.zhizulian.R;

import jp.wasabeef.glide.transformations.BlurTransformation;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;

import static com.bumptech.glide.request.RequestOptions.bitmapTransform;

/**
 * Created by 18865 on 2017/12/22.
 */

public class GlideUtils {
    public static void loadNotice(Context context, String url, ImageView imageView) {
        Glide.with(context).load(url).apply(bitmapTransform(new RoundedCornersTransformation(8, 0))).into(imageView);
    }

    public static void loadNews(Context context, String url, ImageView imageView) {
        Glide.with(context).load(url).apply(RequestOptions.centerCropTransform()).into(imageView);
    }

    public static void loadVideo(Context context, String url, ImageView imageView) {
        Glide.with(context).asDrawable().load(url).apply(RequestOptions.centerCropTransform().error(R.drawable.play_loading)).into(imageView);
    }

    public static void loadQRCode(Context context, String url, ImageView imageView) {
        Glide.with(context).load(url).into(imageView);
    }

//    public static void loadStrockAvatar1(Context context, String url, ImageView imageView) {
//        Glide.with(context).load(url).apply(
//                RequestOptions.bitmapTransform(
//                        new GlideCricleTransform(context
//                                , 2
//                                , context.getResources().getColor(R.color.white)
//                        ))
//                        .error(R.drawable.touxiang)
//                        .placeholder(R.drawable.touxiang))
//                .into(imageView);
//    }

//    public static void loadAvatar(Context context, String url, ImageView imageView) {
//        Glide.with(context).load(url).apply(RequestOptions.bitmapTransform(new GlideCricleTransform(context)).error(R.drawable.touxiang).placeholder(R.drawable.touxiang)).into(imageView);
//    }

    public static void loadAvatar(Context context, String url, ImageView imageView) {
        Glide.with(context).load(url).apply(new RequestOptions().error(R.drawable.defaulttouxiang).placeholder(R.drawable.defaulttouxiang)).into(imageView);
    }
}
